package com.smart.parking.controller.backstage;

import com.smart.parking.config.Result;
import com.smart.parking.entity.LoginLogEntity;
import com.smart.parking.service.LoginLogService;
import com.smart.parking.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * 登录日志表
 *
 * @author ciyun
 */
@RestController
@RequestMapping("/loginlog")
public class LoginLogController {
    @Autowired
    private LoginLogService loginLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = loginLogService.queryPage(params);

        return Result.ok().put("page", page);
    }

    /**
     * 查询本用户登录日志
     */
    @GetMapping("/getLoginLogList")
    public Result getLoginLogList(@RequestParam("userId") Long userId){
        List<LoginLogEntity> loginLogList = loginLogService.getLoginLogList(userId);
        return Result.ok().put("loginLogList",loginLogList);
    }

    /**
     * 超级管理查询所有用户登录信息
     */
    @GetMapping("/getLoginLogLists")
    public Result getLoginLogLists(){
        List<LoginLogEntity> loginLogLists = loginLogService.getLoginLogLists();
        return Result.ok().put("loginLogLists",loginLogLists);
    }

}
